<?php
//include 'lib/form.php';

page::$panel = true;
array_shift(page::$URL);

if ( empty(page::$URL[0]) ) {
  page::$page_id = 'editor';
} else {
  page::$page_id = page::$URL[0];
}


if ( ! page::$ajax ) {
  page::$html = new Template( 'panel' );
}

if ( db::ok() ) {
  $sql = "SELECT * FROM `mods` WHERE `type`='panel_menu' ORDER BY `order` ASC";
  $res = db::q($sql);
  $menu = '';
  while ( $r = $res->assoc() ) {
    $menu .= '  <a href="/panel/'.$r['mod'].'/">'.$r['name']."</a>\n";
  }
  page::$html->assign( 'menu', $menu );
  
  in_array( page::$page_id, array('login','logout') ) || system::require_rights(80);
  
  include 'panel/_'.page::$page_id.'.php';
  $sql = "SELECT * FROM `content` WHERE `type`='page' OR (NOT `hide`) OR `menu`";
  page::$html->assign( 'tree', db::q($sql)->arr() );
}

?>